local s15__bingyi = fk.CreateSkill {
  name = "s15__bingyi"
}

Fk:loadTranslationTable {
  ["s15__bingyi"] = "秉壹",
  [":s15__bingyi"] = "结束阶段，你可以展示所有手牌，将牌堆顶至多X张牌分配给X名角色各一张牌（X为你的手牌中红黑色牌较多的一方）。",

  ["#s15__bingyi-choose"] = "选择任意名角色，将牌堆顶等量张牌分配给这些角色各一张牌",

  ["$s15__bingyi1"] = "公正无私，秉持如一。",
  ["$s15__bingyi2"] = "诸君看仔细了！",
}

s15__bingyi:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(s15__bingyi.name) and player.phase == Player.Finish and
        not player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = player:getCardIds("h")
    player:showCards(cards)
    if player.dead then return end
    local tos = room:askToChoosePlayers(player, {
      skill_name = s15__bingyi.name,
      min_num = 1,
      max_num = 6,
      targets = room.alive_players,
      prompt = "#s15__bingyi-choose",
    })
    if #tos > 0 then
      player:drawCards(#tos, s15__bingyi.name)
      room:askToYiji(player, {
        skill_name = s15__bingyi.name,
        min_num = 0,
        max_num = #tos,
        cards = player:getCardIds("h"),
        targets = tos,
        cancelable = false,
      })
    end
  end,
})

return s15__bingyi
